package cn.edu.xjtu.nbrash.xbarsuite.terry;

import com.google.zxing.client.android.Contents;
import com.google.zxing.client.android.Intents;

import cn.edu.xjtu.nbrash.xbarsuite.R;
import cn.edu.xjtu.nbrash.xbarsuite.R.id;
import cn.edu.xjtu.nbrash.xbarsuite.R.layout;
import cn.edu.xjtu.nbrash.xbarsuite.R.menu;
import cn.edu.xjtu.nbrash.xbarsuite.zxingdemo.RashDisplayActivity;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.os.Build;

public class EncodeText extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_encode_text);

		// EditText textText = (EditText) findViewById(R.id.text_text);

	}

	public void back(View v) {
		finish();
	}

	public void showQR(View v) {
		String text = ((TextView) findViewById(R.id.text_text)).getText()
				.toString();
		if (text != null && !text.equals("")) {
			Intent intent = new Intent(this, RashDisplayActivity.class);
			// ACTION 是 ENCODE
			intent.setAction(Intents.Encode.ACTION);
			// 类型是TEXT，这里可以有很多中类型，具体参见QRCodeEncoder源码
			intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
			// 数据，这里是字符串
			intent.putExtra(Intents.Encode.DATA, text);
			startActivity(intent);
		}
	}

}
